package Java面试周阳.阻塞队列.生消模型;

public class ProdConsumerTraditionDemo01 {
    public static void main(String[] args) {
        ShareData shareData = new ShareData();

        // t1线程生产
        new Thread(() -> {
            for(int i=0; i<5; i++) {
                try {
                    shareData.increment();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, "t1").start();

        // t2线程消费
        new Thread(() -> {
            for(int i=0; i<5; i++) {
                try {
                    shareData.decrement();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, "t2").start();
    }
}
